package com.example.park2212.fg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.launcher.ARouter
import com.example.lib_base.mvvm.BaseFragment
import com.example.park2212.R
import com.example.park2212.adapter.HomeAdapter
import com.example.park2212.databinding.FragmentHomeBinding
import com.example.park2212.fgviewmodel.HomeViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class HomeFragment : BaseFragment<FragmentHomeBinding,HomeViewModel>() {
    lateinit var homeAdapter: HomeAdapter
    override fun initView() {
        homeAdapter = HomeAdapter()
        binding.rvGong.adapter = homeAdapter
        binding.rvGong.layoutManager = LinearLayoutManager(context)
       viewModel.home(1)

        binding.ivCarManager.setOnClickListener {
            ARouter.getInstance().build("/app/emp/EmpActivity").navigation()
        }

        binding.ivCarClock.setOnClickListener {
            ARouter.getInstance().build( "/app/sign/SignActivity").navigation()
        }
        binding.ivCarTui.setOnClickListener {
            ARouter.getInstance().build( "/app/merchant/MerchantActivity").navigation()
        }
        binding.ivCarXun.setOnClickListener {
            ARouter.getInstance().build( "/app/patrol/PatrolActivity").navigation()
        }

        binding.ivCarVip.setOnClickListener {
            ARouter.getInstance().build("/app/member/MemberActivity").navigation()
        }


    }

    override fun initData() {
        viewModel.homeSuccess.observe(this){
            homeAdapter.data.clear()
            homeAdapter.data.addAll(it)
            homeAdapter.notifyDataSetChanged()
        }
    }

}